package com.suikajy.layoutmanagerdemo;

import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import butterknife.Bind;
import butterknife.ButterKnife;


/**
 * Created by suikajy on 2016/12/7.
 */

public class MyAdapter extends RecyclerView.Adapter<MyAdapter.VH> {

    @Override
    public VH onCreateViewHolder(ViewGroup parent, int viewType) {
        View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.item, parent, false);
        VH vh = new VH(v);
        return vh;
    }

    @Override
    public void onBindViewHolder(VH holder, int position) {
        holder.mLlItem.setBackgroundColor(Utils.getRandomColor());
        holder.mTvItem.setText(String.valueOf(position));
    }

    @Override
    public int getItemCount() {
        return 100;
    }

    class VH extends RecyclerView.ViewHolder {
        @Bind(R.id.tv_item)
        TextView mTvItem;
        @Bind(R.id.iv_item)
        ImageView mIvItem;
        @Bind(R.id.ll_item)
        LinearLayout mLlItem;
        public VH(View itemView) {
            super(itemView);
            ButterKnife.bind(this,itemView);
        }
    }

}
